package fr.upmf.miam.imageannotation;

import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.provider.MediaStore;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;


public class ImageAnnotationGalleryAdapter extends CursorAdapter {
	
	public ImageAnnotationGalleryAdapter(Context context, Cursor c) {
		super(context, c);
	}

	public void bindView(View view, Context context, Cursor cursor) {
		int id = cursor.getInt(0);
		Bitmap b = MediaStore.Images.Thumbnails.getThumbnail(context.getContentResolver(), id, MediaStore.Images.Thumbnails.MINI_KIND, null);
		((ImageView)view).setImageBitmap(b);		
	}

	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		ImageView view = new ImageView(context);
		view.setPadding(10, 10, 20, 10);
		bindView(view, context, cursor);
		return view;
	}

}
